'use strict';
const {
  Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
  class Laboratory extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
      models.Laboratory.hasMany(models.Equipment,{foreignKey:'laboratoryId',as:'Equipments'})
      models.Laboratory.hasMany(models.bookinfo,{foreignKey:'bookLaboratoryId',as:'bookinfos'})
    }
  }
  Laboratory.init({
    laboratoryName: DataTypes.STRING,
    openTime:DataTypes.STRING,
    closeTime:DataTypes.STRING,
    isApplyBook:DataTypes.INTEGER,
    max:DataTypes.INTEGER
  }, {
    sequelize,
    modelName: 'Laboratory',
  });
  return Laboratory;
};